package cn.com.cennavi.bean;

import java.io.Serializable;

/**
 * didi原始点数据
 * 
 * @ClassName: DiDiOrignalBean
 * @Description: TODO（这里用一句话描述这个类的作用）
 * @author bull
 * @date 2016年3月17日 下午5:57:30
 *
 */
public class DiDiOrignalBean implements Serializable{
	/**
	 * @Fields serialVersionUID : TODO（用一句话描述这个变量表示什么）
	 */
	private static final long serialVersionUID = 1L;
	public String carID;
	public double lon;
	public double lat;
	public long timeStamp;
	public double speed;// m/s
	public double direction;
	public int flag;
	public String gpsAttr;
	public String tag01;
	public String tag02;
	public String tag03;

	public static DiDiOrignalBean parseData(String line) {
		String[] dataArr = line.split(",");
		if (dataArr.length == 11) {
			DiDiOrignalBean didi = new DiDiOrignalBean();
			didi.carID = dataArr[0];
			didi.lon = Double.parseDouble(dataArr[1]);
			didi.lat = Double.parseDouble(dataArr[2]);
			didi.timeStamp = Long.parseLong(dataArr[3]);
			didi.speed = Double.parseDouble(dataArr[4]);
			didi.direction = Double.parseDouble(dataArr[5]);
			didi.flag = Integer.parseInt(dataArr[6]);
			didi.gpsAttr = dataArr[7];
			didi.tag01 = dataArr[8];
			didi.tag02 = dataArr[9];
			didi.tag03 = dataArr[10];
			return didi;
		}else{
			return null;
		}
	
	}

	public String toSting() {
		StringBuffer sb = new StringBuffer();
		sb.append(this.carID);
		sb.append(",");
		sb.append(this.lon);
		sb.append(",");
		sb.append(this.lat);
		sb.append(",");
		sb.append(this.timeStamp);
		sb.append(",");
		sb.append(this.speed);
		sb.append(",");
		sb.append(this.direction);
		sb.append(",");
		sb.append(this.flag);
		sb.append(",");
		sb.append(this.gpsAttr);
		sb.append(",");
		sb.append(this.tag01);
		sb.append(",");
		sb.append(this.tag02);
		sb.append(",");
		sb.append(this.tag03);
		return sb.toString();
	}

	// public static class Compare implements Comparator<DiDiOrignalBean>,
	// Serializable {
	//
	// @Override
	// public int compare(DiDiOrignalBean o1, DiDiOrignalBean o2) {
	// // TODO Auto-generated method stub
	// int result = o1.timeStamp > o2.timeStamp ? 1 : (o1.timeStamp ==
	// o2.timeStamp ? 0 : -1);
	// return result;
	// }// 比较器
	//
	// // public int compare(Object o1, Object o2) {
	// // DiDiOrignalBean s1 = (DiDiOrignalBean) o1;// 转型
	// // DiDiOrignalBean s2 = (DiDiOrignalBean) o2;// 转型
	// // int result = s1.timeStamp > s2.timeStamp ? 1 : (s1.timeStamp ==
	// // s2.timeStamp ? 0 : -1);
	// //
	// // return result;
	// // }
	//
	// }

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String line = "1,2999412,121.54024,31.17186,1447716299,3.8,334.1,6,LOC_GPS,GCJ_02,DD_TAXI,DriverNotWorking";
		DiDiOrignalBean bd = DiDiOrignalBean.parseData(line);
		if (bd == null) {
//			System.out.println("asdas");
		}else
		{
//			System.out.println("asdasdasdasd");
		}
		// System.out.println(bd.toSting());

	}

}
